﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MappingGenerator.Formatting;

namespace MappingGenerator.Template
{
    public partial class EntityTemplate
    {
        private string _namespace = "Entities";
        public string Namespace
        {
            get { return _namespace; }
            set { _namespace = value; }
        }

        private IDbObjectNameFormatter _formatter;

        public TableInfo Table { get; set; }
        public EntityTemplate(TableInfo table):this(table,new DbObjectNameFormatter())
        {
        }

        public EntityTemplate(TableInfo table,IDbObjectNameFormatter formatter)
        {
            Table = table;
            _formatter = formatter;
        }
        public string PropertyName(ColumInfo column)
        {
            return _formatter.MemberName(column);
        }
        public string BackingFieldName(ColumInfo column)
        {
            string fieldName = PropertyName(column);
            fieldName = string.Format("_{0}{1}", char.ToLower(fieldName[0]), fieldName.Substring(1));
            return fieldName;
        }
        public string EntityName()
        {
            return _formatter.EntityName(Table);
        }
    }
}
